﻿using Microsoft.EntityFrameworkCore;
using ShopeeWebApi.Model.Enum;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace ShopeeWebApi.Model
{
    [Index(nameof(AmzRSRID), nameof(AmzFormRawID))]
    public class Category
    {
        public Category()
        {

        }
        public Category(string oname,string dname,EnumPlatform enumPlatform,long?categoryId,long?parentCategoryId)
        {
            OriginalName = oname;
            DisplayName = dname;
            Platform = enumPlatform;
            CategoryId = categoryId;
            CategoryParentId = parentCategoryId;
        }
        public Category(string oname, string dname, EnumPlatform enumPlatform,int formID,int rID)
        {
            OriginalName = oname;
            DisplayName = dname;
            Platform = enumPlatform;
            AmzFormRawID = formID;
            AmzRSRID = rID;
        }
        public long Id { get; set; }
      
        [Comment("字段名称")]
        public string OriginalName { set; get; }

        [Comment("展示名称")]
        public string DisplayName { set; get; }
    
        [Comment("添加时间")]
        public DateTime AddTime { get; set; } = DateTime.Now;     

        [Comment("所属平台")]
        /// <summary>
        /// 所属平台
        /// </summary>
        public EnumPlatform Platform { get; set; }

        [Comment("分类目录ID")]
        public long? CategoryId { set; get; }

        [Comment("所属父目录ID")]
        public long? CategoryParentId { set; get; }

        [Comment("该分类下所有属性和值")]
        /// <summary>
        /// 该分类下所有属性和值
        /// </summary>
        public string? Datas { get; set; }
        [Comment("amazon-ProductExcelID")]
        public int? AmzFormRawID { get; set; }
        [Comment("amazon-HtmlID")]
        public int? AmzRSRID { get; set; }

        [InverseProperty("Category")]
        public List<AreaCategoryRelation> Categorys { get; set; } 
        
        [InverseProperty("NewCategory")]
        public List<AreaCategoryRelation> NewCategorys { get; set; }    
        
        public List<CategoryAttrRelation> CategoryAttrRelations { get; set; }
    }
}